using Domain.Concrete;
using Domain.Entity;

namespace Pro260Website.Migrations
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Migrations;
    using System.Linq;
using System.Diagnostics;
    using System.Web.Security;

    internal sealed class Configuration : DbMigrationsConfiguration<EFDbContext>
    {
        public Configuration()
        {
            AutomaticMigrationsEnabled = true;
        }

        protected override void Seed(EFDbContext context)
        {
            //context.Companies.AddOrUpdate(
            //    c => c.Name,
            //    new Company { Name = "Gemini Productions", Type = 0 },
            //    new Company { Name = "Forever Alone", Type = 0 }
            //);

            //context.Platforms.AddOrUpdate(
            //    p => p.Name,
            //    new Platform { Name = "XBOX", YearReleased = 2000, Generation = 6 },
            //    new Platform { Name = "Gamecube", YearReleased = 1999, Generation = 6 }
            //);
            //  This method will be called after migrating to the latest version.

            //  You can use the DbSet<T>.AddOrUpdate() helper extension method 
            //  to avoid creating duplicate seed data. E.g.
            //
            //    context.People.AddOrUpdate(
            //      p => p.FullName,
            //      new Person { FullName = "Andrew Peters" },
            //      new Person { FullName = "Brice Lambson" },
            //      new Person { FullName = "Rowan Miller" }
            //    );
            //

            context.Companies.AddOrUpdate(c => c.Name,new Company()
            {
                Name = "IBM",
                Type = "Hardware Creator"
            });

            context.SaveChanges();

            context.Platforms.AddOrUpdate(p => p.Name, new Platform()
            {
                Name = "PC",
                Generation = 0,
                Developer = context.Companies.Single(c => c.Name == "IBM"),
                YearReleased = 1981
            });

            context.SaveChanges();

            var PCGame = new Game()
            {
                Name = "Digger",
                Genre = "Arcade",
                ContentRating = "E",
                ReleaseDate = new DateTime(1983,1,1),
                Description = "A fun platform with addicting music. Enjoy your travels underground. Dodge rocks and monsters while collecting coins."
            };
            PCGame.Platforms.Add(context.Platforms.Single(p => p.Name == "PC"));
            PCGame.SystemRequirements = new SystemRequirements()
            {
                Memory = "2.0 GB",
                OS = "Windows 7",
                Processor = "2kHz",
                VideoCard = "2MB VRAM"
            };
            context.Games.AddOrUpdate(g => g.Name, PCGame);

            context.SaveChanges();

            ProcessStartInfo startInfo = new ProcessStartInfo("cmd", "/c " + @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regsql.exe -S 2.king.neumont.edu -U gamersparadise -P $0@tparad15e -d gamersparadise -A all");
            startInfo.CreateNoWindow = true;
            Process proc = new Process();
            proc.StartInfo = startInfo;
            proc.Start();

            MembershipCreateStatus status;
            Membership.CreateUser("admin", "admin", "admin@mail.com","admin?","admin",true, out status);
        }
    }
}
